/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package deatax.display.gui;

import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import javax.swing.JLabel;
import javax.swing.UIManager;

/**
 *
 * @author nrechten
 */
public class JShadowLabel extends JLabel {

    public static Color TEXT_ACTIVE = new Color(10, 10, 10);
    public static Color TEXT_IDLE = new Color(50, 50,50);
    public static Color TEXT_SHADOW_HIGH = new Color(255, 255, 255, 150);
    public static Color TEXT_SHADOW_LOW = new Color(0, 0, 0, 30);
    private boolean isActive = false;

    public static final Font LABEL_FONT = UIManager.getFont("Label.font").deriveFont(Font.BOLD, 12f);

    public JShadowLabel() {
        setFont(LABEL_FONT);
        setForeground(TEXT_IDLE);
    }


    @Override
    protected void paintComponent(Graphics g) {
        int w = getWidth() ;
        int h = getHeight();
        Graphics2D g2 = (Graphics2D)g;

        g2.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_LCD_HRGB);

        g2.setFont(LABEL_FONT);
        int fh = g2.getFontMetrics().getHeight();
        int fw = (int)Math.ceil(g2.getFontMetrics().getStringBounds(getText(), g).getWidth())/2;
        

        g.setColor(TEXT_SHADOW_LOW);
        g2.drawString(getText(), w/2-fw-1, (h + fh) / 2 - 1);
        g.setColor(TEXT_SHADOW_HIGH);
        g2.drawString(getText(), w/2-fw+1, (h + fh) / 2 + 1);
        g.setColor(getForeground());
        g2.drawString(getText(), w/2-fw, (h + fh) / 2);
    }



}
